<template>
  <scroll-view
    scroll-y
    enable-flex
    class="imageFour_box"
    @scrolltolower="handleScroll"
  >
    <view class="image_box" v-for="(item, index) in allList" :key="index" @click="handleImage(item)">
      <image :src="item.img" mode="widthFix" />
    </view>
  </scroll-view>
</template>

<script>
export default {
  props: ["urlAll"],
  data() {
    return {
      allList: [],
      isMore: true,
    };
  },
  mounted() {
    this.getList();
  },
  watch: {
    urlAll() {
        this.isMore=true
        this.allList=[]
      this.urlAll.parmas.skip=0
      this.getList();
    },
  },
  methods: {
    getList() {
      this.request({
        url: this.urlAll.url,
        data: this.urlAll.parmas,
      }).then((res) => {
        console.log(res);
        if (res.data.res.videowp.length === 0) {
          this.isMore = false;
          uni.showToast({
            title: "没有更多了",
            icon: "none",
          });
          return;
        }
        this.allList = [...this.allList,...res.data.res.videowp];
      });
    },
    handleScroll() {
      if (this.isMore) {
        this.urlAll.parmas.skip += this.urlAll.parmas.limit;
        this.getList();
      } else {
        uni.showToast({
          title: "没有更多了",
          icon: "none",
        });
      }
    },
    handleImage(item){
        getApp().globalData.viedo = item
        uni.navigateTo({
             url: '/pages/viedoPlay/index'
        });
    }
  },
};
</script>

<style lang="scss" scope>
.imageFour_box {
  display: flex;
  flex-wrap: wrap;
  height: calc(100vh - 42px);
  .image_box {
    width: 33.33%;
    border: 5rpx solid #fff;
  }
}
</style>
